public class test{
    public static void main(String[] args)
    {
        long [] f = new long[10000];
        long [] a = {1, -2, 3, 5, -1};
        f[0] = -100000;
        long ans = (long) -1e10;
        for(int i = 0; i < a.length; i++)
        {
            int j = i + 1;
            f[j] = Math.max(f[j - 1] + a[i], a[i]);
            ans = Math.max(ans, f[j]);
        }
        System.out.println(ans);
    }
}

